package cn.liwq.study.demo.netty.lab.mahjong.common.protocol;

import io.netty.buffer.ByteBuf;
import lombok.Data;

/**
 * @author lweiqiang
 * @date 2021/5/8
 */
@Data
public final class MahjongProtocolHeader {
    /** 版本号 */
    private int version;
    /** 命令 */
    private int cmd;
    /** 请求 id */
    private int reqId;

    public void encode(ByteBuf buffer) {
        buffer.writeInt(version);
        buffer.writeInt(cmd);
        buffer.writeInt(reqId);
    }

    public void decode(ByteBuf msg) {
        this.version = msg.readInt();
        this.cmd = msg.readInt();
        this.reqId = msg.readInt();
    }
}
